package com.wbdgj.ui.booking;

import android.content.Context;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.wbdgj.R;
import com.wbdgj.base.BaseActivity;
import com.wbdgj.ui.mine.Coupon01Fragment;
import com.wbdgj.ui.mine.Coupon02Fragment;
import com.wbdgj.ui.mine.Coupon03Fragment;
import com.wbdgj.ui.mine.YhjActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class BookingInfoActivity extends BaseActivity {

    private Context context = this;
    private static TabLayout mTabLayout;
    @BindView(R.id.destination_viewpager)
    ViewPager mViewPager;

    private MyFragmentPagerAdapter adapter;
    private List<Fragment> fragments;

    private BookingInfo01Fragment bookingInfo01Fragment;
    private BookingInfo02Fragment bookingInfo02Fragment;
    private BookingInfo03Fragment bookingInfo03Fragment;

    @Override
    protected int getLayoutResId() {
        return R.layout.ui_booking_info;
    }

    @Override
    protected void initView() {
        mTabLayout = (TabLayout) findViewById(R.id.destination_tab_layout);
        fragments = new ArrayList<>();
        fragments.add(bookingInfo01Fragment = (BookingInfo01Fragment) Fragment.instantiate(context,BookingInfo01Fragment.class.getName()));
        fragments.add(bookingInfo02Fragment = (BookingInfo02Fragment)Fragment.instantiate(context,BookingInfo02Fragment.class.getName()));
        fragments.add(bookingInfo03Fragment = (BookingInfo03Fragment)Fragment.instantiate(context,BookingInfo03Fragment.class.getName()));
        adapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(adapter);
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.getTabAt(0).setText("设施政策");
        mTabLayout.getTabAt(1).setText("酒店介绍");
        mTabLayout.getTabAt(2).setText("交通娱乐");
    }

    private class MyFragmentPagerAdapter extends FragmentPagerAdapter {
        public MyFragmentPagerAdapter(FragmentManager fm) {
            super(fm);

        }
        @Override
        public Fragment getItem(int position) {
            return fragments.get(position);
        }

        @Override
        public int getCount() {
            return fragments.size();
        }
    }
}
